<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        function showImage(src, resolve, reject) {
            let image = new Image();
            image.src = src;
            image.onload = () => {   //程序调用
                resolve(image)
            };
            image.onerror = reject;
        }

        showImage('time.jpg', function (image) {  //程序调用 
            console.log("图片加载")
            document.body.appendChild(image)
        }, function () {
            console.log("图片加载失败")
        })
        console.log("i am back!!!")
    </script>
</body>


</html>